<script setup>

import {selectPage, select, getAll} from "@/api/system/apartment/erecord";
import da from "element-ui/src/locale/lang/da";


export default {
  data() {
    return {
      dialogVisible: false,
      queryParams: {
        number: "",
      },
      total: 1,
      tableData: [],
      form: {
        number: ""
      },
      type: [],
    }
  }, methods: {
    resetQuery() {
      this.queryParams = {};
      this.resetForm("queryParams");
      this.queryMethods();
    },
    queryMethods() {
      let that = this;
      select(that.queryParams.number).then(function (data) {
        that.tableData = data.data;
      })
    },
    handleSizeChange(pageSize) {
      this.queryParams.pageSize = pageSize;
      this.queryMethods();
    },
    handleCurrentChange(pageNum) {
      this.queryParams.pageNum = pageNum;
      this.queryMethods();
    },
    addInfoShow() {
      this.dialogVisible = true;
    },
    payClick() {
      window.open("http://localhost:9002/alipay/pay?number=" + this.form.number + "&payType=" + this.form.payType + "&money=" + this.form.money)

    }
  },

  created() {
    let  that = this;
    that.queryMethods();
    getAll().then(function (data) {
      that.type = data.data;
    })
  }
}
</script>

<template>
  <div class="app-container">
    <el-form :model="queryParams" :inline="true">
      <el-form-item label="设备编号">
        <el-input
          v-model="queryParams.number"
          placeholder="设备编号"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryMethods()">搜索</el-button>

        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-button type="primary" icon="el-icon-search" size="mini" @click="addInfoShow()">新增</el-button>

    <el-table
      :data="tableData"
      stripe
      style="width: 100%">
      <el-table-column
        prop="id"
        label="序号"
        align="center"
        width="210">
      </el-table-column>
      <el-table-column
        prop="serialNumber"
        label="流水号"
        align="center"
        width="200">
      </el-table-column>
      <el-table-column
        prop="roomNumber"
        label="设备编号"
        align="center"
        width="200">
      </el-table-column>
      <el-table-column
        prop="residentName"
        label="设备位置"
        align="center"
        width="200">
      </el-table-column>
      <el-table-column
        label="充值类型 "
        prop="rechargeType"
        align="center"
        width="80">
      </el-table-column>
      <el-table-column
        prop="rechargeBeforeMoney"
        label="充值前金额"
        align="center"
        width="120">
      </el-table-column>
      <el-table-column
        prop="rechargeMoney"
        label="充值金额"
        align="center"
        width="120">
      </el-table-column>
      <el-table-column
        prop="money"
        label="余额"
        align="center"
        width="120">
      </el-table-column>
      <el-table-column
        prop="rechargeTime"
        label="充值时间"
        align="center"
        width="200">
      </el-table-column>
    </el-table>


    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="20%">


      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="设备编号">
          <el-select style="width: 190px;" v-model="form.number"
                     placeholder="设备编号">
            <el-option
              v-for="o in type"
              :key="o.equipmentNumber"
              :value="o.equipmentNumber"
              :label="o.equipmentNumber"
            ></el-option>
          </el-select>
        </el-form-item>


        <el-form-item label="支付类型">
          <el-select style="width: 190px;" v-model="form.payType"
                     placeholder="请选择支付类型">
            <el-option label="支付宝" :value="1"/>
          </el-select>
        </el-form-item>
        <el-form-item label="充值金额">
          <el-input v-model="form.money" style="width: 190px;"/>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="payClick">支付</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<style scoped lang="scss">

</style>
